/*var tmpl_main = '\
	<div id="uqe_main_frame">\
		<header class="frame-header">\
			<div class="uqe-header-right">\
			</div>\
			<div class="uqe-header-footprint control_header">\
				<ul class="breadcrumb">\
				  <li class="active">播放控制</li>\
				</ul>\
			</div>\
			<div class="control-frame-content">\
			</div>\
		</header>\
	</div>';
var tmpl_body = '<div class="uqe-pane pane-player">\
			<div id="d_player" class="ui-dialog ui-widget ui-widget-content ui-corner-top">\
				<object classid="clsid:6A5C3024-A51D-4892-A473-060387A11644" id="NLEPlugin" style="display:none;" width="100" height="50"></object>\
				<div id="player_toolbar" class="ui-dialog-titlebar ui-widget-header ui-corner-top">&nbsp;</div>\
				<div id="buttons" class="toolbar"></div>\
				<div id="playewrapper" class="ui-dialog-content ui-widget-content"></div>\
			</div>\
		</div>\
		<div class="uqe-pane pane-list">\
			<header class="header">\
				<label>评测单节目列表</label>\
				<div class="toolbar right">\
					<a class="btn btn-success btn-xs"><span class="glyphicon glyphicon-plus"></span>选择评测单</a>\
				</div>\
			</header>\
			<div class="body">\
				<table id="monadTable">\
				</table>\
			</div>\
		</div>\
		<div class="uqe-pane pane-rate">\
			<header class="header">\
				<label>专家评委</label>\
			</header>\
			<div class="body">\
				<table id="raterTable">\
				</table>\
			</div>\
		</div>\
		<div class="uqe-pane pane-point">\
			<header class="header">\
				<label>打点信息</label>\
			</header>\
			<div class="body">\
				<table id="pointerTable">\
				</table>\
			</div>\
		</div>\
		<div class="uqe-pane pane-report">\
			<header class="header">\
				<label>质检结果</label>\
			</header>\
			<div class="body">\
			</div>\
		</div>';*/
var appraiseMonads = [ {
	monadName : '展会评测单1',
	appraiseTime : '2014-8-26',
	templateName : '日常评测',
	programCount : '15',
	monadStatus : '评测中',
	programs : [
	            {id:'programName_1',programName:'测试节目1',produration:'48',columnName:'测试栏目1',audio:'立体声',programStatus:'未播',fileName:'preview1.wmv'},
	            {id:'programName_2',programName:'测试节目2',produration:'49',columnName:'测试栏目2',audio:'单声道',programStatus:'未播',fileName:'preview2.wmv'},
	            {id:'programName_3',programName:'测试节目3',produration:'48',columnName:'测试栏目3',audio:'立体声',programStatus:'未播',fileName:'preview3.wmv'},
	            {id:'programName_4',programName:'测试节目4',produration:'49',columnName:'测试栏目4',audio:'单声道',programStatus:'未播',fileName:'preview4.wmv'},
	            {id:'programName_5',programName:'测试节目5',produration:'48',columnName:'测试栏目5',audio:'单声道',programStatus:'未播',fileName:'preview5.wmv'},
	            {id:'programName_1',programName:'测试节目6',produration:'48',columnName:'测试栏目1',audio:'立体声',programStatus:'未播',fileName:'preview1.wmv'},
	            {id:'programName_2',programName:'测试节目7',produration:'49',columnName:'测试栏目2',audio:'单声道',programStatus:'未播',fileName:'preview2.wmv'},
	            {id:'programName_3',programName:'测试节目8',produration:'48',columnName:'测试栏目3',audio:'立体声',programStatus:'未播',fileName:'preview3.wmv'},
	            {id:'programName_4',programName:'测试节目9',produration:'49',columnName:'测试栏目4',audio:'单声道',programStatus:'未播',fileName:'preview4.wmv'},
	            {id:'programName_5',programName:'测试节目10',produration:'48',columnName:'测试栏目5',audio:'单声道',programStatus:'未播',fileName:'preview5.wmv'},
	            {id:'programName_1',programName:'测试节目11',produration:'48',columnName:'测试栏目1',audio:'立体声',programStatus:'未播',fileName:'preview1.wmv'},
	            {id:'programName_2',programName:'测试节目12',produration:'49',columnName:'测试栏目2',audio:'单声道',programStatus:'未播',fileName:'preview2.wmv'},
	            {id:'programName_3',programName:'测试节目13',produration:'48',columnName:'测试栏目3',audio:'立体声',programStatus:'未播',fileName:'preview3.wmv'},
	            {id:'programName_4',programName:'测试节目14',produration:'49',columnName:'测试栏目4',audio:'单声道',programStatus:'未播',fileName:'preview4.wmv'},
	            {id:'programName_5',programName:'测试节目15',produration:'48',columnName:'测试栏目5',audio:'单声道',programStatus:'未播',fileName:'preview5.wmv'}
	            ]
} ,{
	monadName : '展会评测单2',
	appraiseTime : '2014-8-27',
	templateName : '评奖评测',
	programCount : '5',
	monadStatus : '未评测',
	programs : [
	            {id:'programName_1',programName:'测试节目16',produration:'48',columnName:'测试栏目1',audio:'立体声',programStatus:'未播',fileName:'preview1.wmv'},
	            {id:'programName_2',programName:'测试节目17',produration:'49',columnName:'测试栏目2',audio:'单声道',programStatus:'未播',fileName:'preview2.wmv'},
	            {id:'programName_3',programName:'测试节目18',produration:'48',columnName:'测试栏目3',audio:'立体声',programStatus:'未播',fileName:'preview3.wmv'},
	            {id:'programName_4',programName:'测试节目19',produration:'49',columnName:'测试栏目4',audio:'单声道',programStatus:'未播',fileName:'preview4.wmv'},
	            {id:'programName_5',programName:'测试节目20',produration:'48',columnName:'测试栏目5',audio:'单声道',programStatus:'未播',fileName:'preview5.wmv'}
	            ]

},{
	monadName : '展会评测单3',
	appraiseTime : '2014-8-28',
	templateName : '日常评测',
	programCount : '5',
	monadStatus : '未评测',
	programs : [
	            {id:'programName_1',programName:'测试节目21',produration:'48',columnName:'测试栏目1',audio:'立体声',programStatus:'未播',fileName:'preview1.wmv'},
	            {id:'programName_2',programName:'测试节目22',produration:'49',columnName:'测试栏目2',audio:'单声道',programStatus:'未播',fileName:'preview2.wmv'},
	            {id:'programName_3',programName:'测试节目23',produration:'48',columnName:'测试栏目3',audio:'立体声',programStatus:'未播',fileName:'preview3.wmv'},
	            {id:'programName_4',programName:'测试节目24',produration:'49',columnName:'测试栏目4',audio:'单声道',programStatus:'未播',fileName:'preview4.wmv'},
	            {id:'programName_5',programName:'测试节目25',produration:'48',columnName:'测试栏目5',audio:'单声道',programStatus:'未播',fileName:'preview5.wmv'}
	            ]

}];
var raters = [
             {name:'评委A',status:'在线',appraise:'已评分'},
             {name:'评委B',status:'在线',appraise:'已评分'},
             {name:'评委C',status:'在线',appraise:'已评分'},
             {name:'评委D',status:'在线',appraise:'未评分'},
             {name:'评委E',status:'在线',appraise:'已评分'},
             {name:'评委F',status:'在线',appraise:'已评分'},
             {name:'评委G',status:'离线',appraise:'未评分'},
             {name:'评委H',status:'离线',appraise:'未评分'},
             {name:'评委I',status:'离线',appraise:'未评分'},
             {name:'评委J',status:'离线',appraise:'已评分'},
             {name:'评委K',status:'离线',appraise:'未评分'},
             ];

var pointers = [
                {rater:'评委A',time:'00:05:00',problem:'图像'},
                {rater:'评委B',time:'00:15:00',problem:'图像'},
                {rater:'评委B',time:'00:21:00',problem:'声音'},
                {rater:'评委D',time:'00:29:00',problem:'声音'},
                {rater:'评委D',time:'00:30:00',problem:'图像'},
                {rater:'评委C',time:'00:55:00',problem:'图像'},
                {rater:'评委F',time:'00:55:00',problem:'图像'}
                ];

$(function() {
		var player = MediaPlayerFactory.getPlayer('xamlobject', document.getElementById('playewrapper'),$('#d_player').width(),$('#d_player').height(), 1);
		var windowHref = window.location.href;
		var url = windowHref.substring(0,windowHref.lastIndexOf('/')+1);
		var frame = $('#uqe_main_frame');
//		if(frame.size() <= 0) {
//			frame = $(tmpl_main).appendTo('body');
			// 用户信息显示及退出按钮
			var dright = frame.find('.uqe-header-right').empty();
			var now = new Date();
			$('<span class="session-info time">').html(now.format('yyyy-MM-dd HH:mm:ss')).appendTo(dright);
			$('<span class="session-info user">').html('当前用户：admin').appendTo(dright);
			$('<a class="session-info logoff" data-loading-text="退出中..">退出</a>').appendTo(dright);
//			$(tmpl_body).appendTo('.control-frame-content');
			var showMonadTable = function(appraiseMonad){
				$('#monadTable').empty();
				var table = $('#monadTable');
				var app_th = $('<tr>');
				$('<td>').html('<b>评测单名称</b>').appendTo(app_th);
				$('<td>').html('<b>评测时间</b>').appendTo(app_th);
				$('<td>').html('<b>评分模板</b>').appendTo(app_th);
				$('<td>').html('<b>节目数量</b>').appendTo(app_th);
				$('<td>').html('<b>状态</b>').appendTo(app_th);
				app_th.appendTo(table);
				var app_tr = $('<tr>');
				$('<td>').html(appraiseMonad.monadName).appendTo(app_tr);
				$('<td>').html(appraiseMonad.appraiseTime).appendTo(app_tr);
				$('<td>').html(appraiseMonad.templateName).appendTo(app_tr);
				$('<td>').html(appraiseMonad.programCount).appendTo(app_tr);
				$('<td>').html(appraiseMonad.monadStatus).appendTo(app_tr);
				app_tr.appendTo(table);
				
				var pro_th = $('<tr>');
				$('<td>').html('<b>节目名称</b>').appendTo(pro_th);
				$('<td>').html('<b>时长</b>').appendTo(pro_th);
				$('<td>').html('<b>栏目名称</b>').appendTo(pro_th);
				$('<td>').html('<b>声道</b>').appendTo(pro_th);
				$('<td>').html('<b>节目状态</b>').appendTo(pro_th);
				pro_th.appendTo(table);
				var programs = appraiseMonad.programs;
				 
				$(programs).each(function(index,program){
					var pro_tr = $('<tr>');
					pro_tr.addClass('appraisePro');
					pro_tr.mousemove(function(){
						$(this).addClass("proMouseOn");
					});
					pro_tr.mouseout(function(){
						$(this).removeClass("proMouseOn");
					});
					pro_tr.click(function(){
						player.load(url+'program/'+program.fileName);
						$(this).parent().children().each(function(index,td){
							if($(td).children('td:last').html()=="正在播放"){
								$(td).children('td:last').html('已播');
							}
						});
						$(this).children('td:last').html('正在播放');
					});
					$('<td>').html(program.programName).appendTo(pro_tr);
					$('<td>').html(program.produration).appendTo(pro_tr);
					$('<td>').html(program.columnName).appendTo(pro_tr);
					$('<td>').html(program.audio).appendTo(pro_tr);
					$('<td>').html(program.programStatus).appendTo(pro_tr);
					pro_tr.appendTo(table);
				});
			}
			var raterTable= $('#raterTable');
			var r_th = $('<tr>');
			$('<td>').html('<b>评委</b>').appendTo(r_th);
			$('<td>').html('<b>状态</b>').appendTo(r_th);
			$('<td>').html('<b>评分</b>').appendTo(r_th);
			r_th.appendTo(raterTable);
			for(var i=0;i<raters.length;i++){
				var r_tr = $('<tr>');
				$('<td style="padding:5px 0;">').html(raters[i].name).appendTo(r_tr);
				$('<td style="padding:5px 0;">').html(raters[i].status).appendTo(r_tr);
//				var img = $('<img src ="images/yes.png" >');
				$('<td style="padding:5px 0;">').html(raters[i].appraise).appendTo(r_tr);
				r_tr.appendTo(raterTable);
			} 
			
			var pointerTable= $('#pointerTable');
			var poi_th = $('<tr>');
			$('<td>').html('<b>评委</b>').appendTo(poi_th);
			$('<td>').html('<b>时码</b>').appendTo(poi_th);
			$('<td>').html('<b>问题</b>').appendTo(poi_th);
			poi_th.appendTo(pointerTable);
			for(var i=0;i<pointers.length;i++){
				var poi_tr = $('<tr>');
				$('<td style="padding:5px 0;">').html(pointers[i].rater).appendTo(poi_tr);
				$('<td style="padding:5px 0;">').html(pointers[i].time).appendTo(poi_tr);
				$('<td style="padding:5px 0;">').html(pointers[i].problem).appendTo(poi_tr);
				poi_tr.appendTo(pointerTable);
			}
			var table = $('#checkTable');
			var ap_th = $('<tr>').appendTo(table);
			$('<td>').html('<b>评测单名称</b>').appendTo(ap_th);
			$('<td>').html('<b>评测时间</b>').appendTo(ap_th);
			$('<td>').html('<b>评分模板</b>').appendTo(ap_th);
			$('<td>').html('<b>节目数量</b>').appendTo(ap_th);
			$('<td>').html('<b>状态</b>').appendTo(ap_th);
			$(appraiseMonads).each(function(index,appraiseMonad){
				var tr = $('<tr style="padding:1em;">').appendTo(table);
				tr.addClass('appraisePro');
				tr.mousemove(function(){
					$(this).addClass("proMouseOn");
				});
				tr.mouseout(function(){
					$(this).removeClass("proMouseOn");
				});
				tr.click(function(){
					$('#appriaseMonads').hide('normal');
					showMonadTable(appraiseMonad);
				});
				$('<td>').html(appraiseMonad.monadName).appendTo(tr);
				$('<td>').html(appraiseMonad.appraiseTime).appendTo(tr);
				$('<td>').html(appraiseMonad.templateName).appendTo(tr);
				$('<td>').html(appraiseMonad.programCount).appendTo(tr);
				$('<td>').html(appraiseMonad.monadStatus).appendTo(tr);
			});
			$('#showMonads').click(function(){
				$('#appriaseMonads').show('normal');
			});
			showMonadTable(appraiseMonads[0]);
//		} 
	});

